clear all
use YOUR_DIRECTORY\politicalclimate_foranalysis_final.dta


*Table 1 Descriptive Stats
summarize gw_belief i.demog_race demog_gender college older r_win i.ppa 
summarize gw_belief if ppa==1
summarize gw_belief if ppa==2
summarize gw_belief if ppa==4

*Table 2
*Col 1
rdrobust gw_belief m_percent , all  covs(yfe2-yfe8) vce(cluster stateid)
*Col 2
rdrobust gw_belief m_percent , all covs(yfe2-yfe8  rfe2-rfe5 demog_gender) vce(cluster stateid)
*Col 3
rdrobust gw_belief m_percent if ppa==1 , all  covs(yfe2-yfe8 ) vce(cluster stateid)
*col 4
rdrobust gw_belief m_percent if ppa==1 , all covs(yfe2-yfe8  rfe2-rfe5 demog_gender ) vce(cluster stateid) 
*col 5
rdrobust gw_belief m_percent if ppa==2 , all covs(yfe2-yfe8   ) vce(cluster stateid)  
*col 6
rdrobust gw_belief m_percent if ppa==2 , all covs(yfe2-yfe8  rfe2-rfe5 demog_gender ) vce (cluster stateid)

**Parametric RD
*Finding bandwidth
*linear controls (Table 3)
rdbwselect gw_belief m_percent, all covs(yfe2-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) vce(cluster stateid)
*10.051


*Parametric regressions (Table 3) (Linear Controls)

*(Stata Huber/White standard errors--not in paper) Estimated only to check coefficient point estimates below for Table 3
reg gw_belief c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa i.year_match i.demog_gender i.demog_race  i.stateid if m_percent>=-10.051 & m_percent<=10.051 , cluster(stateid) 
reg gw_belief c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa   i.demog_gender i.demog_race  if m_percent>=-10.051 & m_percent<=10.051 , cluster(stateid) 
reg gw_belief c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa   i.demog_gender i.demog_race i.stateid i.year_match older college if m_percent>=-10.051 & m_percent<=10.051 , cluster(stateid) 
reg gw_belief c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa  if m_percent>=-10.051 & m_percent<=10.051 , cluster(stateid) 

*Table 3
*calculate Cameron, Gelbach, and Miller (2008) wild cluster robust bootstrapped p-values
*only keep observations within optimal bandwidth for cgmwildboot. Note that you must do this step to get correct p-values.
keep if  m_percent>=-10.051 & m_percent<=10.051

*Col 1
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49 , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*Col 2
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 rfe2-rfe5 demog_gender , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*Col 3
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 rfe2-rfe5 demog_gender older college yfe2-yfe8 state_fe1-state_fe49 , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*Col 4
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*reload data for analysis. 
clear all
use politicalclimate_foranalysis_final.dta

*Placebo tests (Local Linear, Table 4)
*col 1
rdrobust white m_percent  ,  all covs(yfe2-yfe8) vce(cluster stateid)
*col 2
rdrobust older m_percent ,  all  covs(yfe2-yfe8) vce(cluster stateid)
*col 3
rdrobust demog_gender m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid)
*col 4
rdrobust college m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) 


*Placebo tests (Parametric, Table 5)

*optimal bandwidth calculation
rdbwselect white m_percent,  all covs(yfe1-yfe7 demog_gender pfe2-pfe3) kernel(uniform) vce(cluster stateid)
*8.691
*(Stata Huber/White standard errors--not in paper) Estimated only to check coefficient point estimates below 
reg white c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.stateid i.demog_gender if m_percent>=-8.691 & m_percent<=8.691 , cluster(stateid) 

**calculate Cameron, Gelbach, and Miller (2008) wild cluster robust bootstrapped p-values
*only keep observations within optimal bandwidth for cgmwildboot. Note that you must do this step to get correct p-values.
keep if  m_percent>=-8.691 & m_percent<=8.691 
*Col 1
cgmwildboot white m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8  demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*reload data
clear all
use politicalclimate_foranalysis_final.dta
rdbwselect older m_percent,  all covs(yfe1-yfe7 demog_gender pfe2-pfe3 rfe2-rfe5) kernel(uniform) vce(cluster stateid)
*9.515
reg older c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.stateid i.demog_gender i.demog_race if m_percent>=-9.515 & m_percent<=9.515 , cluster(stateid) 
keep if  m_percent>=-9.515 & m_percent<=9.515
*Col 2
cgmwildboot older m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

clear all
use politicalclimate_foranalysis_final.dta

rdbwselect demog_gender m_percent,  all covs(yfe1-yfe7 pfe2-pfe3 rfe2-rfe5) kernel(uniform) vce(cluster stateid)
*10.354
reg demog_gender c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.stateid  i.demog_race if m_percent>=-10.354 & m_percent<=10.354, cluster(stateid) 
keep if  m_percent>=-10.354 & m_percent<=10.354
*Col 3
cgmwildboot demog_gender m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

clear all
use politicalclimate_foranalysis_final.dta

rdbwselect college m_percent,  all covs(yfe1-yfe7 rfe2-rfe5 pfe2-pfe3 demog_gender) kernel(uniform) vce(cluster stateid)
*8.771
reg college c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.stateid  i.demog_race i.demog_gender if m_percent>=-8.771 & m_percent<=8.771, cluster(stateid) 
keep if  m_percent>=-8.771 & m_percent<=8.771
*Col 4
cgmwildboot college m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

clear all
use politicalclimate_foranalysis_final.dta

*Placebo tests Partisan Affiliation (Table 6)
*col 1
rdrobust republican m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid)

*col 2
rdrobust republican m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform) 

*col 3
rdrobust democrat m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid)

*col 4
rdrobust democrat m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform)

*col 5
rdrobust independent m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid)

*col 6
rdrobust independent m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform)


*Alternative dep. variable, anthropogenic global warming, local linear (Table 7)
*these are in order for columns 1-9
rdrobust believer_human m_percent, all covs(yfe1-yfe7 ) vce(cluster stateid)
rdrobust believer_human m_percent, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender ) vce(cluster stateid)
rdrobust believer_human m_percent, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender) vce(cluster stateid) kernel(uniform)
rdrobust believer_human m_percent if demog_polp==1 , all covs(yfe1-yfe7 ) vce(cluster stateid) 
rdrobust believer_human m_percent if demog_polp==1 , all covs(yfe1-yfe7 rfe2-rfe5 demog_gender ) vce(cluster stateid) 
rdrobust believer_human m_percent if demog_polp==1, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender ) vce(cluster stateid) kernel(uniform)
rdrobust believer_human m_percent if demog_polp==2 , all covs(yfe1-yfe7 ) vce(cluster stateid) 
rdrobust believer_human m_percent if demog_polp==2 , all covs(yfe1-yfe7 rfe2-rfe5 demog_gender) vce(cluster stateid) 
rdrobust believer_human m_percent if demog_polp==2, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender) vce(cluster stateid) kernel(uniform)


*Alternative dep. variable, anthropogenic global warming, parametric(Table 8)
clear all
use politicalclimate_foranalysis_final.dta
rdbwselect believer_human m_percent, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender pfe2-pfe3) vce(cluster stateid) kernel(uniform)
*8.360
keep if  m_percent>=-8.360 & m_percent<=8.360

*(Stata Huber/White standard errors--not in paper) Estimated only to check coefficient point estimates below 
reg believer_human c.m_percent##ppa c.int_rd##ppa c.r_win##ppa  i.year_match i.demog_gender i.demog_race  i.stateid   , cluster(stateid) 

**calculate Cameron, Gelbach, and Miller (2008) wild cluster robust bootstrapped p-values
*Col 1
cgmwildboot believer_human m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)


reg believer_human c.m_percent##ppa c.int_rd##ppa c.r_win##ppa i.demog_gender i.demog_race  , cluster(stateid) 
*col 2
cgmwildboot believer_human m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3  rfe2-rfe5 demog_gender , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

keep if  m_percent>=-7.409 & m_percent<=7.409
*col 3
reg believer_human c.m_percent##ppa c.int_rd##ppa c.r_win##ppa  i.demog_gender i.demog_race    , cluster(stateid) 
cgmwildboot believer_human m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3  rfe2-rfe5 demog_gender , cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)



**********************Appendix A Tables****************************************

clear all
use politicalclimate_foranalysis_final.dta

*Table A1
prtest demog_gender, by (above6)
prtest college, by (above6) 
prtest white, by (above6) 
prtest older, by (above6) 
prtest conservative, by (above6) 
prtest republican, by (above6) 
prtest democrat, by (above6) 
prtest independent, by (above6) 

clear all
use politicalclimate_foranalysis_final.dta

*Appendix Table A2
rdrobust gw_belief m_percent_p1 , all covs(yfe1-yfe7 ) vce(cluster stateid)
rdrobust gw_belief m_percent_p1 , all covs(yfe1-yfe7) kernel(uniform) vce(cluster stateid)


*Appendix Table A3
rdbwselect gw_belief m_percent_p1 , all covs(yfe1-yfe7 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) vce(cluster stateid)
*7.479
clear all
use politicalclimate_foranalysis_final.dta

reg gw_belief c.m_percent_p1##ppa c.int_rd_p1##ppa c.r_win_p1##ppa ib1.ppa i.year_match i.demog_gender rfe2-rfe5  i.stateid if m_percent_p1>=-7.479 & m_percent_p1<=7.479 , cluster(stateid) 
keep if  m_percent_p1>=-7.479 & m_percent_p1<=7.479
*col 1
cgmwildboot gw_belief m_percent_p1 int_rd_p1 r_win_p1 p2Xwinp1 p3Xwinp1 p2Xmp1 p3Xmp1 p2Xintp1 p3Xintp1 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

clear all
use politicalclimate_foranalysis_final.dta

reg gw_belief c.m_percent_p1##ppa c.int_rd_p1##ppa c.r_win_p1##ppa ib1.ppa i.year_match i.demog_gender rfe2-rfe5  i.stateid if m_percent_p1>=-10.051 & m_percent_p1<=10.051 , cluster(stateid) 
keep if  m_percent_p1>=-10.051 & m_percent_p1<=10.051

*col 2
cgmwildboot gw_belief m_percent_p1 int_rd_p1 r_win_p1 p2Xwinp1 p3Xwinp1 p2Xmp1 p3Xmp1 p2Xintp1 p3Xintp1 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*Appendix Table A4 (Uses CCES panel data)
*Must first load CCES panel data!
clear all
use cces_panel_foranalysis
*First, using built-in Stata commands to verify coefficient point estimates (not in paper)
xtreg gw_belief r_win  i.year_match [pw=weight] , fe vce(cluster statefips)
reg d2gw d2r_m d2fe12 d2fe14 [pw=weight], cluster(statefips)

xtreg gw_belief r_win  i.year_match [pw=weight] if democ_2010==1, fe vce(cluster statefips)
reg d2gw d2r_m d2fe12 d2fe14 [pw=weight] if democ_2010==1, cluster(statefips)

xtreg gw_belief r_win  i.year_match [pw=weight] if repub_2010==1 , fe vce(cluster statefips)
reg d2gw d2r_m d2fe12 d2fe14 [pw=weight] if repub_2010==1, cluster(statefips)

*Next,using wild cluster bootstrapped standard errors to find p-values
*Col 1
cgmwildboot d2gw d2r_m d2fe12 d2fe14 [pw=weight] , cluster(statefips) bootcluster(statefips) reps(1000) seed(053118)

*Col 2
keep if democ_2010==1
cgmwildboot d2gw d2r_m d2fe12 d2fe14 [pw=weight] , cluster(statefips) bootcluster(statefips) reps(1000) seed(053118)

clear all
use cces_panel_foranalysis

*Col 3
keep if repub_2010==1
cgmwildboot d2gw d2r_m d2fe12 d2fe14 [pw=weight] , cluster(statefips) bootcluster(statefips) reps(1000) seed(053118)


*Appendix Table A5
*Col 1
clear all
use politicalclimate_foranalysis_final.dta

rdbwselect conservative m_percent, all covs(yfe4-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform)  vce(cluster stateid)
*10.698

reg conservative c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa i.year_match i.demog_gender i.demog_race i.stateid  if m_percent>=-10.698 & m_percent<=10.698 , cluster(stateid) 
keep if m_percent>=-10.698 & m_percent<=10.698 
cgmwildboot conservative m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe4-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*col 2
*uses cces cross-sectional data
*must first load CCES cross-sectional data!
clear all
use cces_full_foranalysis
rdbwselect conservative m_percent,  vce(cluster statefips) weights(weight)  covs(pfe2-pfe3 male1 rfe1-rfe4) all kernel(uniform)
*Note optimal bandwidth calc. doesn't work when including year fixed effects
*7.108
reg conservative c.m_percent##ppa  c.r_win##ppa c.int_rd##ppa ib1.ppa  i.gender rfe1-rfe4  i.year_match i.statefips [pw=weight] if m_percent>=-7.108 & m_percent<=7.108, cluster(statefips) 
keep if m_percent>=-7.108 & m_percent<=7.108
cgmwildboot conservative m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe1-yfe9 rfe2-rfe5 gender state_fe1-state_fe49[pw=weight], cluster(statefips) bootcluster(statefips) reps(1000) seed(053118)

*Appendix Table A6
*uses cces cross-sectional data
*must first load CCES cross-sectional data!
clear all
use cces_full_foranalysis
reg news_informed male i.race_condensed i.year_match i.statefips i.college  i.older i.ppa [pw=weight], cluster(statefips)

*Appendix Table A7
clear all
use politicalclimate_foranalysis_final.dta
summarize white demog_gender college  older r_win if believer_human==1 & gw_belief==1 & m_percent>=-9.23 & m_percent<=9.23 & ppa==1
summarize white demog_gender college  older r_win if believer_human==0 & gw_belief==1 & m_percent>=-9.23 & m_percent<=9.23 & ppa==1
summarize white demog_gender college  older r_win if gw_belief==0 & m_percent>=-9.23 & m_percent<=9.23 & ppa==1

summarize white demog_gender college  older r_win if believer_human==1 & gw_belief==1 & m_percent>=-9.848 & m_percent<=9.848 & ppa==2
summarize white demog_gender college  older r_win if believer_human==0 & gw_belief==1 & m_percent>=-9.848 & m_percent<=9.848 & ppa==2
summarize white demog_gender college  older r_win if gw_belief==0 & m_percent>=-9.848 & m_percent<=9.848 & ppa==2




**********Online Appendix OA******************

clear all
use politicalclimate_foranalysis_final.dta

*Online Appendix Table OA1 (Uniform kernel)
rdrobust gw_belief m_percent, all covs(yfe2-yfe8 ) vce(cluster stateid) kernel(uniform)
rdrobust gw_belief m_percent, all covs(yfe2-yfe8  rfe2-rfe5 demog_gender) vce(cluster stateid) kernel(uniform)
rdrobust gw_belief m_percent if ppa==1, all covs(yfe2-yfe8 ) vce(cluster stateid) kernel(uniform)
rdrobust gw_belief m_percent if ppa==1, all covs(yfe2-yfe8  rfe2-rfe5 demog_gender) vce(cluster stateid) kernel(uniform)
rdrobust gw_belief m_percent if ppa==2, all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform)
rdrobust gw_belief m_percent if ppa==2, all covs(yfe2-yfe8  rfe2-rfe5 demog_gender) vce(cluster stateid) kernel(uniform)

*Online Appendix Table OA2
clear all
use politicalclimate_foranalysis_final.dta

*Quadrant A1
reg gw_belief i.demog_race older demog_gender college i.year_match i.stateid i.ppa, cluster(stateid)
predict yhatA1
rdrobust yhatA1 m_percent, vce(cluster stateid) all

*Quadrant A2
reg gw_belief i.demog_race older demog_gender college i.year_match i.stateid, cluster(stateid)
predict yhatA2
rdrobust yhatA2 m_percent, vce(cluster stateid) all

*Quadrant B1
reg gw_belief i.demog_race older demog_gender college i.ppa i.year_match , cluster(stateid)
predict yhatB1
rdrobust yhatB1 m_percent, vce(cluster stateid) all

*Quandrant B2
reg gw_belief i.demog_race older demog_gender college i.year_match , cluster(stateid)
predict yhatB2
rdrobust yhatB2 m_percent, vce(cluster stateid) all



*Online Appendix Table OA3
*Col 1
rdrobust republican m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) h(8.391) b(17.992)
*Col 2
rdrobust republican m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform) h(9.609) b(20.092)
*Col 3
rdrobust republican m_percent ,  all covs(yfe2-yfe8) vce(cluster stateid) kernel(uniform) h(10.051) b(22.709)
*Col 4
rdrobust republican m_percent if college==0,  all covs(yfe2-yfe8) vce(cluster stateid)
*Col 5
rdrobust republican m_percent if college==1,  all covs(yfe2-yfe8) vce(cluster stateid)
*Col 6
rdrobust independent m_percent if college==0,  all covs(yfe2-yfe8) vce(cluster stateid)
*Col 7
rdrobust independent m_percent if college==1,  all covs(yfe2-yfe8) vce(cluster stateid)

*Online Appendix Table OA4
*uses cces cross-sectional data
*must first load CCES cross-sectional data!
clear all
use cces_full_foranalysis

rdrobust republican m_percent, all vce(cluster statefips) covs(yfe1-yfe9) weights(weight)
rdrobust republican m_percent, all vce(cluster statefips) weights(weight)  kernel(uniform)


rdrobust democrat m_percent, all vce(cluster statefips) covs(yfe1-yfe9) weights(weight)  
rdrobust democrat m_percent, all vce(cluster statefips) weights(weight) kernel(uniform)

rdrobust independent m_percent, all vce(cluster statefips) covs(yfe1-yfe9) weights(weight)  
rdrobust independent m_percent, all vce(cluster statefips)  weights(weight) kernel(uniform)

*Online Appendix Table OA5

*50% Optimal BW (Col 1)
clear all
use politicalclimate_foranalysis_final.dta
reg gw_belief c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.demog_gender i.demog_race  i.stateid if m_percent>=-5.0255 & m_percent<=5.0255 , cluster(stateid) 
keep if  m_percent>=-5.0255 & m_percent<=5.0255
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*75% Optimal BW (Col 2)
clear all
use politicalclimate_foranalysis_final.dta
reg gw_belief c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa i.year_match i.demog_gender i.demog_race  i.stateid if m_percent>=-7.538 & m_percent<=7.538 , cluster(stateid) 
keep if  m_percent>=-7.538 & m_percent<=7.538
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)


*At least 1 year in office (Col 3)
clear all
use politicalclimate_foranalysis_final.dta
rdbwselect gw_belief m_percent if yip>=1, all covs(yfe1-yfe7 rfe2-rfe5 demog_gender pfe2-pfe3) vce(cluster stateid) kernel(uniform)
*8.363
reg gw_belief c.m_percent##ppa c.int_rd##ppa c.r_win##ppa ib1.ppa  i.year_match i.demog_gender i.demog_race i.stateid if m_percent>=-8.363 & m_percent<=8.363 & yip>=1 , cluster(stateid) 
keep if  m_percent>=-8.363 & m_percent<=8.363 & yip>=1
cgmwildboot gw_belief m_percent int_rd r_win p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)



*Appendix Table OA6, Limiting Sample to at least 1 year in power

clear all
use politicalclimate_foranalysis_final.dta

rdrobust gw_belief m_percent if yip>=1 , all covs(yfe1-yfe7 ) vce(cluster stateid)
rdrobust gw_belief m_percent if yip>=1 , all covs(yfe1-yfe7 ) kernel(uniform) vce(cluster stateid)

rdrobust gw_belief m_percent if yip>=1 & demog_polp==1, all covs(yfe1-yfe7 ) vce(cluster stateid)
rdrobust gw_belief m_percent if yip>=1 & demog_polp==1, all covs(yfe1-yfe7 )kernel(uniform) vce(cluster stateid)

rdrobust gw_belief m_percent if yip>=1 & demog_polp==2, all covs(yfe1-yfe7 ) vce(cluster stateid)
rdrobust gw_belief m_percent if yip>=1 & demog_polp==2, all covs(yfe1-yfe7 )kernel(uniform) vce(cluster stateid)


*Appendix Table OA7
*First, finding optimal bandwidths for each order of controls
rdbwselect gw_belief m_percent, all covs(yfe2-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) p(2) vce(cluster stateid)
*16.548

rdbwselect gw_belief m_percent, all covs(yfe2-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) p(3) vce(cluster stateid)
*19.296

rdbwselect gw_belief m_percent, all covs(yfe2-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) p(4) vce(cluster stateid)
*24.858

rdbwselect gw_belief m_percent, all covs(yfe2-yfe8 rfe2-rfe5 demog_gender pfe2-pfe3) kernel(uniform) p(5) vce(cluster stateid)
*27.543

*Next, the regressions for Table OA7

reg gw_belief c.m_percent##ppa c.int_rd##ppa c.m_percent2##ppa c.int_rd2##ppa   c.r_win##ppa   i.demog_gender i.demog_race i.stateid i.year_match   if m_percent>=-16.548 & m_percent<=16.548 , cluster(stateid)
keep if  m_percent>=-16.548 & m_percent<=16.548

*col 1
cgmwildboot gw_belief m_percent int_rd r_win int_rd2 m_percent2 p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint p2Xm2 p3Xm2 p2Xint2 p3Xint2 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

clear all
use politicalclimate_foranalysis_final.dta

reg gw_belief c.m_percent##ppa c.int_rd##ppa c.m_percent2##ppa c.int_rd2##ppa c.m_percent3##ppa c.int_rd3##ppa c.r_win##ppa  ib1.ppa i.year_match i.demog_gender i.demog_race i.stateid  if m_percent>=-19.296 & m_percent<=19.296, cluster(stateid) 

*col 2
keep if  m_percent>=-19.296 & m_percent<=19.296
cgmwildboot gw_belief m_percent int_rd r_win int_rd2 m_percent2 int_rd3 m_percent3 p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint p2Xm2 p3Xm2 p2Xint2 p3Xint2 p2Xm3 p3Xm3 p2Xint3 p3Xint3 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)


clear all
use politicalclimate_foranalysis_final.dta

reg gw_belief c.m_percent##ppa c.int_rd##ppa c.m_percent2##ppa c.int_rd2##ppa c.m_percent3##ppa c.int_rd3##ppa c.m_percent4##ppa c.int_rd4##ppa  c.r_win##ppa  ib1.ppa i.year_match i.demog_gender i.demog_race i.stateid if m_percent>=-24.858 & m_percent<=24.858, cluster(stateid) 
*col 3
keep if  m_percent>=-24.858 & m_percent<=24.858
cgmwildboot gw_belief m_percent int_rd r_win int_rd2 m_percent2 int_rd3 m_percent3 int_rd4 m_percent4 p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint p2Xm2 p3Xm2 p2Xint2 p3Xint2 p2Xm3 p3Xm3 p2Xint3 p3Xint3  p2Xm4 p3Xm4 p2Xint4 p3Xint4 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)


clear all
use politicalclimate_foranalysis_final.dta
*col 4
reg gw_belief c.m_percent##ppa c.int_rd##ppa c.m_percent2##ppa c.int_rd2##ppa c.m_percent3##ppa c.int_rd3##ppa c.m_percent4##ppa c.int_rd4##ppa c.m_percent5##ppa c.int_rd5##ppa  c.r_win##ppa  ib1.ppa i.year_match i.demog_gender i.demog_race i.stateid  if m_percent>=-27.543 & m_percent<=27.543, cluster(stateid) keep if  m_percent>=-27.543 & m_percent<=27.543
cgmwildboot gw_belief m_percent int_rd r_win int_rd2 m_percent2 int_rd3 m_percent3 int_rd4 m_percent4 int_rd5 m_percent5 p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint p2Xm2 p3Xm2 p2Xint2 p3Xint2 p2Xm3 p3Xm3 p2Xint3 p3Xint3  p2Xm4 p3Xm4 p2Xint4 p3Xint4 p2Xm5 p3Xm5 p2Xint5 p3Xint5 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)

*Full Sample, Order 5
clear all
use politicalclimate_foranalysis_final.dta
*col 5
reg gw_belief c.m_percent##ppa c.int_rd##ppa c.m_percent2##ppa c.int_rd2##ppa c.m_percent3##ppa c.int_rd3##ppa c.m_percent4##ppa c.int_rd4##ppa c.m_percent5##ppa c.int_rd5##ppa  c.r_win##ppa  ib1.ppa i.year_match i.demog_gender i.demog_race i.stateid , cluster(stateid) 
cgmwildboot gw_belief m_percent int_rd r_win int_rd2 m_percent2 int_rd3 m_percent3 int_rd4 m_percent4 int_rd5 m_percent5 p2Xwin p3Xwin p2Xm p3Xm p2Xint p3Xint p2Xm2 p3Xm2 p2Xint2 p3Xint2 p2Xm3 p3Xm3 p2Xint3 p3Xint3  p2Xm4 p3Xm4 p2Xint4 p3Xint4 p2Xm5 p3Xm5 p2Xint5 p3Xint5 pfe2-pfe3 yfe2-yfe8 rfe2-rfe5 demog_gender state_fe1-state_fe49, cluster(stateid) bootcluster(stateid) reps(1000) seed(053118)


***Online Appendix OB***

*Table OB 2

clear all
use cces_full_foranalysis.dta
rdrobust white m_percent , all vce(cluster statefips) covs(yfe1-yfe9) weights(weight)
rdrobust older m_percent , all vce(cluster statefips) covs(yfe1-yfe9)  weights(weight)
rdrobust gender m_percent, all vce(cluster statefips) covs(yfe1-yfe9) weights(weight)
rdrobust college m_percent , all vce(cluster statefips) covs(yfe1-yfe9)  weights(weight)
rdrobust republican m_percent , all vce(cluster statefips) covs(yfe1-yfe9)  weights(weight)

clear all
use cces_climatechange_foranalysis.dta
rdrobust white m_percent if gw_belief!=., all vce(cluster statefips) covs(yfe2 yfe4-yfe8) weights(weight)
rdrobust older m_percent if gw_belief!=., all vce(cluster statefips) covs(yfe2 yfe4-yfe8)  weights(weight)
rdrobust gender m_percent if gw_belief!=., all vce(cluster statefips) covs(yfe2 yfe4-yfe8) weights(weight)
rdrobust college m_percent if gw_belief!=., all vce(cluster statefips) covs(yfe2 yfe4-yfe8)  weights(weight)
rdrobust republican m_percent if gw_belief!=., all vce(cluster statefips) covs(yfe2 yfe4-yfe8)  weights(weight)

***********************Footnotes/text results******************************
clear all
use politicalclimate_foranalysis_final.dta

*footnote 28
rdrobust gw_belief m_percent if ppa==4 , all covs(yfe2-yfe8   ) vce(cluster stateid) 
rdrobust gw_belief m_percent if ppa==4 , all covs(yfe2-yfe8  rfe2-rfe5 demog_gender ) vce(cluster stateid) 



*footnote 38
*Must first load CCES panel data!
clear all
use cces_panel_foranalysis
*First, verifying coefficient point estimates
reg d2rep d2r_m d2fe12 d2fe14 [pw=weight], cluster(statefips)
xtreg republican r_win  i.year_match [pw=weight] , fe vce(cluster statefips)
*Next, finding wild cluster robust bootstrapped p-values
cgmwildboot d2rep d2r_m d2fe12 d2fe14 [pw=weight], cluster(statefips) bootcluster(statefips) reps(1000) seed(053118)

*footnote 39
*Must first load CCES panel data!
clear all
use cces_panel_foranalysis
reg r_defect2012 gw_belief##r_win i.race i.gender i.education[pw=weight] if year_match==2012, vce(cluster statefips)

*text section 3.5
clear all
use cces_climatechange_foranalysis.dta
rdrobust gw_belief m_percent , all vce(cluster statefips) covs(yfe2 yfe4-yfe8 male1 rfe1-rfe4)  weights(weight)

*text section 4
clear all
use politicalclimate_foranalysis_final.dta
rdrobust conservative m_percent ,  all covs(yfe4-yfe8 rfe2-rfe5 demog_gender ) vce(cluster stateid)

clear all
use cces_full_foranalysis
rdrobust conservative m_percent,  vce(cluster statefips) weights(weight) all


****RD Plots***
clear all
use politicalclimate_foranalysis_final.dta

*1A 
rdplot gw_belief m_percent if m_percent>=-10 &m_percent<=10 , p(1) h(10) nbins(10) kernel(triangular)

*1B
rdplot gw_belief m_percent if m_percent>=-10 &m_percent<=10 & demog_polp==1, p(1) h(10) nbins(10) kernel (triangular)

*1C
rdplot gw_belief m_percent if m_percent>=-10 & m_percent<=10 & demog_polp==2, p(1) h(10) nbins(10) kernel (triangular)

*1D
rdplot gw_belief m_percent if m_percent>=-10 & m_percent<=10 & demog_polp==4, p(1) h(10) nbins(10) kernel (triangular)

gr combine figure1_a.gph figure1_b.gph figure1_c.gph figure1_d.gph, altshrink


***Density Plots****
*3A
DCdensity m_percent , breakpoint(0) generate(Xj Yj r0 fhat se_fhat) b(1) h(10)
drop Xj Yj r0 fhat se_fhat

*3B
DCdensity m_percent if ppa==1, breakpoint(0) generate(Xj Yj r0 fhat se_fhat) b(1) h(10)
drop Xj Yj r0 fhat se_fhat

*3C
DCdensity m_percent if ppa==2, breakpoint(0) generate(Xj Yj r0 fhat se_fhat) b(1) h(10)
drop Xj Yj r0 fhat se_fhat

*3D
DCdensity m_percent if ppa==4, breakpoint(0) generate(Xj Yj r0 fhat se_fhat) b(1) h(10)


gr combine  mccrarydensity_ind_all.gph mccrarydensity_ind_dem.gph mccrarydensity_ind_rep.gph mccrarydensity_ind_ind.gph, altshrink



***End************************

